package edu.biwu.filter;

import jakarta.servlet.*;

import java.io.IOException;

/**
 * 过滤器类的创建:
 * 1.新建一个类,实现jakarta.servlet.Filter接口
 * 2.重写doFilter方法
 */
public class FilterDemo02 implements Filter {

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
        System.out.println("FilterDemo02开始执行" + request + "...." + response);
        chain.doFilter(request, response);

        System.out.println("FilterDemo02结束执行");
        response.setContentType("text/html;charset=UTF-8");
        response.getWriter().write("FilterDemo02的响应");
    }
}
